{literal}
<style>
#ulMenu{list-style:none;width:580px;}
#ulMenu li{float:left;width:95px; border-left:1px #bfbfbf solid; text-align:center;height:60px; line-height:50px;font-size:14px;color:#888888; cursor:pointer;}
#mnuRef{ position:absolute;z-index:100; left:45px; background-color:#ffffff; border:1px solid #BFBFBF;width:155px; display:none;}
#mnuRef ul{list-style:none; padding:0; margin:0;}
#mnuRef ul li{ cursor:pointer;width:100%; height:30px; line-height:30px; text-align:left; padding-left:2px; overflow:hidden;text-overflow:ellipsis; white-space:nowrap;}
#mnuRef ul li:hover{ background-color:#EEE;} 
#ulAppLst{list-style:none; padding:0; margin:0;}
#ulAppLst li{float:left;width:110px;height:133px;position: relative; padding-top:10px;}
#ulAppLst li table{width:100%;height:100%;}
#ulAppLst li td{line-height:20px; vertical-align:bottom;}
#ulAppLst li img{width:100px;height:90px; cursor:pointer;}
#ulAppLst li div{position:absolute; top:110px;left:5px;font-size: 10px;}
#ulAppLst li input{position:absolute; top:84px;left:0px;}
#ulAppLst li #groupico{width:20px;right:12px; bottom:40px; height:auto; position:absolute;}
#appListDivPageNav .curr {color: #D2D2D2;font-size: 12px;}
#menu2_top{width:95px;height:12px;position:absolute;z-index:200;left:408px;top:83px;background-color:#ffffff;border-left:1px #b4b3b0 solid;border-right:1px #b4b3b0 solid; display:none;}
#menu2{display:none;width:170px;height:auto;background-color:#ffffff; position:absolute;z-index:100;left:408px;top:94px;border:1px #b4b3b0 solid;}
#menu2 ul{list-style:none;width:150px; padding:0; margin:auto;}
#menu2 ul li{height:40px; text-align:left; line-height:40px;border-bottom:1px dashed #aaaaaa; padding-left:8px; font-size:12px; cursor:pointer;}
</style>
<script language=JavaScript>
var headerMenuShow = false;
var headerCheckedBatchId = "";
var headerIsCheckedApp = false;
var gAppSt = 4;
var gAppSid = 0;
function showMenu(t,obj)
{
	 if(t==0)
	 {
		  window.location.href="?act=main";
		 
	 }
	 else if(t==1)
	 {
		 window.location.href="?act=upload";
	 }
	 else if(t==2)
	 {
		 //window.location.href="?act=type&tid=1";
		 if(headerMenuShow)
		 {
			 hideMenu1()
		 }
		 else
		 {
		 	setMenuBgColor("目录",false);
	
		 }
		 //window.location.href="?act=type";
	 }
	 else if(t==3)
	 {
		 window.location.href="?act=user";
	 }
	 else if(t==4)
	 {
		 window.location.href="?act=ref";
	 }
	 else if(t==5)
	 {
		 window.location.href="?act=filegroup";
	 }
}
function headerOpenPage(url)
{
    var curUrl = window.location.href;
    if(curUrl.indexOf("op=detail")==-1)
    {
    	getPage(url);
    }
    else
    {
        window.location.href="?act=main"+url.replace("?act=ajax&op=getLstFile","");
    }
}
function hideMenu1()
{
			if(headerMenuShow)
			{
			 var jq = $($("#ulMenu").find("li")[3]);
			 headerMenuShow = false;
			 $("#menu2").slideUp(500,function(){
			 $("#menu2_top").hide();
		 	 jq.css("background-color","#f7f7f7");
		 	 jq.css("border-top","none");
			 jq.css("font-weight","normal");
				 });
			}
}
function showMyFav()
{
    setHeaderPos("我的收藏夹");
	headerOpenPage("?act=ajax&op=getLstFileFront&k=myFav");
}
function setHeaderPos(txt)
{
	if(txt=="")
	{
		$("#headerPos").html("");
	}
	else
	{
		$("#headerPos").html("<a href='?act=main'>首页</a>&nbsp;&nbsp;&nbsp;&nbsp;>&nbsp;&nbsp;&nbsp;&nbsp;"+txt);
	}
}
function setMenuBgColor(txt,isInit)
{
	$("#ulMenu").find("li").each(function(){
		     var jq = $(this);
			 if(jq.html().indexOf(txt)!=-1)
			 {
				jq.css("color","#FFC019");
				 if(txt=="目录")
				 {
					jq.css("font-weight","bold");
                    if(!isInit)
					{
						jq.css("border-top","1px #bfbfbf solid");
						jq.css("background-color","#ffffff");
						$("#menu2_top").show();
		 				headerMenuShow = true;
						$("#menu2").slideToggle(500);
					}
				 }
			 }
			 else
			 {
				 jq.css("color","#888");
			 }
			 });
}
$(function(){
	$("#ulMenu").find("li").each(function(){
		 $(this).css("color","#888");
	});
	var act =  getQueryString("act");
	if(act=="main")
	{
		 setMenuBgColor("首页",true);
		 //setHeaderPos("");
	}
	else if(act=="upload")
	{
		 setMenuBgColor("素材上传",true);
		// setHeaderPos($($("#ulMenu").find("li")[1]).html());
	}
	else if(act=="type")
	{
		setMenuBgColor("目录",true);
		 //setHeaderPos($($("#ulMenu").find("li")[2]).html());
	}
	else if(act=="user")
	{
		 setMenuBgColor("用户",true);
		 //setHeaderPos($($("#ulMenu").find("li")[3]).html());
	}
	else if(act=="ref")
	{
		  setMenuBgColor("推荐",true);
		 //setHeaderPos($($("#ulMenu").find("li")[4]).html());
	}
	else if(act=="filegroup")
	{
		  setMenuBgColor("主题发布",true);
		 setHeaderPos("主题发布");
	}
	$.get("?act=ajax&op=getNavData&id=14",function(d){
		var j = eval("("+d+")");
		$("#myName").html(j.name);
        $("#spanAppNum").html(j.appnum);
		if(j.rid==1 || j.rid==4)
		{
			headerIsCheckedApp = true;
		}
		//alert(j.appnum);
		$("#menu2ul").append('<li data="0">全部</li>');
		for(i=0;i<j.menu.length;i++)
		{
			$("#menu2ul").append('<li data="'+j.menu[i].id+'">'+j.menu[i].name+'</li>');
		}
		$("#menu2 li:last").css("border","none");
		$("#menu2ul").find("li").each(function(){
				var jo = $(this);
				var id = jo.attr("data");	
			    jo.click(function(){
				  hideMenu1();
				  setHeaderPos(jo.html());
				  $("#tblsel_tdType").find("a").each(function(){
					  if($(this).html()==jo.html())
					  {
						  $(this).css("color","#FFC019");
					  }
					  else
					  {
						   $(this).css("color","#000000");
					  }
					  });
				 
				   window.location.href="?act=type&tid="+id;
				  });
				 //jo.mouseover(function(){$(this).css("background-color","#EEE");})
				 //jo.mouseleave(function(){$(this).css("background-color","#FFFFFF");})
			});
		});
		$("#menu2").mouseleave(function(e) {
                hideMenu1();
            });

	$("#dialog-applylist").dialog({
			autoOpen: false,
			height: 600,
			width: 800,
			modal: true,
			buttons: {
 
				"关闭": function() {
					 $("#dialog-applylist").dialog("close");
				}
			},
			close: function() {
			
			}
		});
	$("#dialog-tips").dialog({
			autoOpen: false,
			height: 200,
			width: 300,
			modal: true,
			buttons: {
 				"是": function() {
					 tipsClickYes();
					 $("#dialog-tips").dialog("close");
				},
				"否": function() {
					 tipsClickNo();
					 $("#dialog-tips").dialog("close");
				}
			},
			open:function(event, ui){
				$(".ui-dialog-titlebar-close", $(this).parent()).hide();
				}
		});
		$("#formAppLstChecked").change(function(){
			
			  var isChecked = this.checked;
			 
				$("#ulAppLst").find("input:checkbox").each(function(){
 
					this.checked= isChecked;
					});
			});
		var doWhat = getQueryString("do");
		if(doWhat=="openAppWin")
		{
			headerIsCheckedApp = true;
			headerCheckedBatchId = getQueryString("bid");

			showAppListWin();
		}
	$("#headerAppListBack").button().click(function(){
		gAppSid=0;
		getAppListPage("?act=ajax&op=getAppLstFile&st="+gAppSt+"&src=edit&ps=21&ajax=getAppListPage&cbid="+headerCheckedBatchId);
		$("#headerAppListBack").css("background","#888");
		});

	$("#headerAppListBack").css("background","#888");
	$("#btnSend").button().click(function(){
		    
			var id = "";
			if($("#formAppLstChecked")[0].checked)
			{
				id="-1";
			}
			else
			{
				$("#ulAppLst").find("input:checkbox").each(function(){
 					if(this.checked)
					{
						id = id + this.value+",";
					}
				});	
			}
			//	$("#ulAppLst").find("input:checkbox").each(function(){
 			//		if(this.checked)
			//		{
			//			id = id + this.value+",";
			//		}
			//	});	
			if(id=="")
			{
				if(headerIsCheckedApp)
				{
					alert("请选择要发布的文件");
				}
				else
				{
					alert("请选择要提交审批的文件");
				}
				return;
			}
			var confirmMsg = "你确认将所选内容提交申请发布吗？";
			var resultMsgOk = "发送成功";
			var doUrl = "?act=ajax&op=sendAppEmail&cid="+$("#selChecker").val();
			if(headerIsCheckedApp)
			{
				if(id=="-1")
				{
					confirmMsg = "确认要发布全部素材 共"+$("#spanAppNum1").html()+"个 吗 ?";
				}
				else
				{
					confirmMsg = "确认将所选内容发布吗？";
				}
				doUrl = "?act=ajax&op=checkPost&bid="+headerCheckedBatchId;
				resultMsgOk = "发布成功";
			}
			else
			{
				if($("#selChecker").val()=="0")
				{
					alert("请选择发送给审批人的邮箱");
					return;
				}
				if(id=="-1")
				{
					confirmMsg = "确认要提交审批全部素材 共"+$("#spanAppNum1").html()+"个 吗 ?";
				}
			}
		    if(confirm(confirmMsg))
			{
				$("#imgLoading").show();
				$("#appSendMsg").html("");
				if(id.indexOf(",")!=-1)
				{
					id = id.substring(0,id.length-1);
				}
				$.post(doUrl,{id:id,sid:gAppSid},function(d){
				$("#imgLoading").hide();
				  var j = eval("("+d+")");
				  if(j.st=="ok")
				  {
				  	if(headerIsCheckedApp|| j.send)
				  	{
					  $("#formAppLstChecked")[0].checked = false;
					 // if(headerIsCheckedApp)
					 // {
					//	  getAppListPage("?act=ajax&op=getAppLstFile&st=5&src=edit&ps=21&ajax=getAppListPage&cbid="+headerCheckedBatchId);
					  //}
					  //else
					  //{
					  	  //getAppListPage("?act=ajax&op=getAppLstFile&st=4&src=edit&ps=21&ajax=getAppListPage");
					  //}
 						   if($("#formAppLstChecked")[0].checked)
						  {
							  $("#ulAppLst").html("");
						  }
						  else
						  {
							   $("#ulAppLst").find("li").each(function(){
								   if($(this).find("#chk")[0].checked)
								   {
									   $(this).hide();
								   }
								   });
						  }
					  
					  $("#appSendMsg").html(resultMsgOk);
					  $("#selSt").change();
				  	}
				 	 else
				  	{
					 	 $("#appSendMsg").html("失败");
				  	}
				  }
				  else
				  {
					  alert("没有选择文件");
				  }
				})
			}
		});
	});
function fav(id)
{
	$.get("?act=ajax&op=addFav&id="+id,function(data){
	    if(data.indexOf("ok")!=-1)
		{
			alert("收藏成功");
		}
	});
}
 
function down(id)
{
	//window.location.href="?act=down&id="+id;
	$.get("?act=down&op=st&id="+id,function(d){});
	window.open("?act=down&id="+id);
}
function doSearch()
{
	var key = $("#txtQuery").val();
	if(key!="")
	{
		headerOpenPage("?act=ajax&op=getLstFileFront&k="+encodeURIComponent(key));
	}
}
function keywordsPress(obj)
{
	$.get("?act=ajax&op=queryKey&k="+obj.value,function(d){
	    var j = eval("("+d+")");
		//alert(j.length);
		if(j.length>0)
		{
			var li = "";
			for(i=0;i<j.length;i++)
			{
				li = li+"<li title='"+j[i]+"'>"+j[i]+"</li>";
			}
			$("#ulMnuRef").html(li);
			$("#mnuRef").show();
			$("#ulMnuRef").find("li").each(function(){
				var jq = $(this);
				jq.click(function(){
					obj.value=jq.html();
					$("#mnuRef").hide();
					doSearch();
					});
				});
		}
		else
		{
			$("#mnuRef").hide();
		}
	});
}
function showAppListWin()
{
    var st = 4;
	if(headerIsCheckedApp)
	{
		
		st = 5;
		$("#dialog-applylist").attr("title","审批文件");
		if(typeof($("#btnSend").find(".ui-button-text").html())=="undefined")
		{
			$("#btnSend").html("确认发布");
		}
		else
		{
			$("#btnSend").find(".ui-button-text").html("确认发布");
		}
		$("#selChecker").hide();
	}
	
	$('#dialog-applylist').dialog('open');
	$("#formAppLstChecked")[0].checked = false;
	gAppSt = st;
	$("#selChecker").html("<option value='0'>选择审批人的邮箱</option>");
	$.get("?act=ajax&op=getCheckUserEmail",function(d){
		var j=eval("("+d+")");
		if(j.st=="ok")
		{
			for(i=0;i<j.data.length;i++)
			{
				$("#selChecker").append("<option value='"+j.data[i].id+"'>"+j.data[i].realName+"_"+j.data[i].email+"</option>");
			}
		}
		});
	getAppListPage("?act=ajax&op=getAppLstFile&st="+st+"&src=edit&ps=21&ajax=getAppListPage&cbid="+headerCheckedBatchId);
}
 
function getAppListPage(url)
{
	$("#formAppLstChecked")[0].checked=false;
	if(url.indexOf("gid")!=-1)
	{
		$("#headerAppListBack").css("background","#597DDB");
	}
	$.get(url,function(data){
		var j = eval("("+data+")");
		if(j.st=="ok")
		{
			$("#ulAppLst").html("");
			if(j.data.total>0)
			{
				var ul = "";
				for(i=0;i<j.data.data.length;i++)
				{
					var name = j.data.data[i].tem_name;
					//var name = name.replace(/<br>/g , '-');
					if(j.data.data[i].mark!=null)
					{;
						name = j.data.data[i].mark;
					}
					if(name.length>30)
					{
						name = name.substring(0,30)+"....";
						
					}
					//ul = ul+'<li><table cellpadding="0" cellspacing="0"><tr><td height="90" width="100" style="width:100px;height:90px;background-image:url('+j.data.data[i].pic+'); background-position:center;background-repeat: no-repeat;background-size:100% 100%;" ><a href="" style="width:100%;height:100%;">3333</a><input id="chk" value="'+j.data.data[i].id+'" type="checkbox"></td></tr><tr><td height="30">'+j.data.data[i].mark+'</td></tr></table></li>';
					var src ="view";
					if(headerIsCheckedApp)
					{
						src = "check";
					}
					if(j.data.data[i].isGroupTop==0)
					{
						ul = ul+'<li><a href="index.php?act=main&op=detail&id='+j.data.data[i].id+'&src='+src+'" target="_blank"><img src="'+j.data.data[i].pic+'" /></a><div title="'+j.data.data[i].tem_name+'">'+name+'</div><input type="checkbox" id="chk" value="'+j.data.data[i].id+'"/></li>';
					}
					else
					{
						ul = ul+'<li><a onclick="getAppListPage(\'?act=ajax&op=getAppLstFile&st='+gAppSt+'&cbid='+headerCheckedBatchId+'&src=edit&ps=21&ajax=getAppListPage&gid='+j.data.data[i].id+'\');gAppSid='+j.data.data[i].id+';" ><img src="'+j.data.data[i].pic+'" /></a><div title="'+j.data.data[i].mark+'">'+j.data.data[i].mark+'</div><input type="checkbox" id="chk" value="'+j.data.data[i].id+'"/><img src="images/group.png" id="groupico"/></li>';
					}
					 
				}
				$("#ulAppLst").append(ul);
				
			}
			$("#appListDivPageNav").html(j.data.pageNav);
			//alert(j.data.total);
			$("#spanAppNum1").html(j.data.total);
			$("#spanAppNum").html(j.data.total);
		}
		});
}
var tipsStep = 0;
function headerShowTips(title,step)
{
	tipsStep = step;
	$("#tips_msg").html(title);
	$("#dialog-tips").dialog("open");
}
function tipsClickYes()
{
	//alert("ccc");
	if(tipsStep==1)
	{
		refreshUpload();
	}
	else if(tipsStep==2)
	{
		gSt = 3;
		$("#btnAddApply").css("background","#597DDB");
 
		showDataPage(true);
		
		//$("#selSt").change();
	}
	else if(tipsStep==3)
	{
		showAppListWin();
	}
	else if(tipsStep==5)
	{
		doPostOne();
	}
}
function tipsClickNo()
{
	//alert("mmm");
	if(tipsStep==1)
	{
		showStFileCount(curDirId);
		$("#dialog-form").dialog("close");
	}
	else if(tipsStep==2)
	{
		lstDir();
		showStFileCount(curDirId,curDirSid);
	}
	else if(tipsStep==3)
	{
	}
}
function checkCookie()
{
}
function doPostOne()
{
	var id = getQueryString("id");
	if(id!="")
	{
		$.get("?act=ajax&op=checkPost",{id:id},function(d){
			var j = eval("("+d+")");
				  if(j.st=="ok")
				  {
					  alert("发布成功");
					  window.opener.getAppListPage("?act=ajax&op=getAppLstFile&st=5&src=edit&ps=21&ajax=getAppListPage");
				  }
				  else
				  {
					  alert("发布失败");
				  }
			});
	}
	
}
</script>
{/literal}
<div id="dialog-tips" title="提示" style="display:none;">
<table height="100%" width="100%">
       <tr>
       <td style="width:200px;height:30px;" id="tips_msg"></td></tr>
       <tr>
       <td style="width:200px;height:30px;" id="tips_msg"></td></tr>
</table>
</div>
<div id="dialog-applylist" title="待审批列表" style="display:none;">
<table height="100%" width="100%">

       <tr>
       <td width="50"> <a id="headerAppListBack" >返回</a></td>
       <td style="width:200px;height:30px;" id="msg">总计&nbsp;<span id="spanAppNum1">0</span>&nbsp;个内容等待审批&nbsp;&nbsp;<input type="checkbox" id="formAppLstChecked"/>全选</td><td  width="400"><select id="selChecker" style="width:auto;"></select>&nbsp;&nbsp;<a id="btnSend">发送审批邮件</a></td><td><span id="appSendMsg"></span><img src="images/loading.gif" height="20" id="imgLoading" style="display:none;"/>
      
       </td></tr>
       <tr><td valign="top" colspan="4">
       <ul id="ulAppLst">
       
       </ul>
       </td></tr>
       <tr>
       <td valign="top"  colspan="3" id="appListDivPageNav" height="20">
       
       </td></tr>
</table>
</div>
<table width="100%" height="126" cellpadding="0" cellspacing="0" style="margin:auto;">
<tr><td align="center" style="border-bottom:1px #aaaaaa dotted;background-color:#f7f7f7">
 <table width="1000" height="126" border="0" cellpadding="0" cellspacing="0" >
  <tr>
    <td width="300px" align="center" valign="middle"><img src="images/toplogo.png" width="150"></td>
    <td valign="top">
    <table width="100%" border="0" height="100%" cellspacing="0" cellpadding="0">
      <tr>
       <td align="right" valign="middle"><a onclick="showAppListWin();" style="color:#888;cursor:pointer;">待审批列表(<span id="spanAppNum">0</span>)</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="showMyFav();" style="color:#888;cursor:pointer;">我的收藏夹<img src="images/fav1.jpg" style="vertical-align:middle; display:none;" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b style="color:#597ddb;" id="myName"></b>&nbsp;&nbsp;<a href="#" target="_self" onClick="logout();" style="color:#888888;">[退出]</a></td>
      </tr>
      <tr><td width="300" align="right" style="position:relative;">
      <ul id="ulMenu">
      <li onclick="showMenu(0,this);_hmt.push(['_setAutoPageview', false]);_hmt.push(['_trackPageview', '/dir/h0']);">首页</li>
      <li onclick="showMenu(1,this);_hmt.push(['_setAutoPageview', false]);_hmt.push(['_trackPageview', '/dir/h1']);">素材上传</li>
      <li onclick="showMenu(5,this);_hmt.push(['_setAutoPageview', false]);_hmt.push(['_trackPageview', '/dir/h5']);">主题发布</li>
      {if $smarty.session.adminUser.id eq 1}
      <li onclick="showMenu(2,this);_hmt.push(['_setAutoPageview', false]);_hmt.push(['_trackPageview', '/dir/h2']);">素材目录</li>
      {else}
      {literal}
      <script>
      $(function(){
		  $("#ulMenu").css("width","480");
		  });
      </script>
      {/literal}
      {/if}
      <li onclick="showMenu(3,this);_hmt.push(['_setAutoPageview', false]);_hmt.push(['_trackPageview', '/dir/h3']);">用户审批</li>
      <li onclick="showMenu(4,this);_hmt.push(['_setAutoPageview', false]);_hmt.push(['_trackPageview', '/dir/h4']);">推荐管理</li>
      </ul>
      <div id="menu2_top"></div>
      <div id="menu2">
      <ul id="menu2ul">
      </ul>
      </div>
      </td>
        </tr>
    </table></td>
  </tr>

</table>

</td></tr>
<tr>
  <td width="10%" height="53" valign="middle" align="center" >
  	<table cellpadding="0" cellspacing="0" width="1000"><tr><td height="50" style="padding-left: 30px;"><span id="headerPos"></span></td>
    <td align="right" width="200" valign="middle" style="position:relative;"><input type="text" id="txtQuery" onKeyUp="keywordsPress(this);"  style="height:21px;vertical-align:middle;"/>
	<div id="mnuRef">
    <ul id="ulMnuRef">
    </ul>
    
    </div>
	</td>
    <td align="right" width="90"><img src="images/btnSearch.png" onClick="doSearch();" style="vertical-align:middle; cursor:pointer;"/></td></tr></table>
  </td>
</tr>
<tr><td style="border-top:1px #aaaaaa dotted;border-bottom:1px #aaaaaa dotted;" height="2"></td></tr>
</table>
